package com.czkt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.czkt.entity.SalChance;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.w3c.dom.stylesheets.LinkStyle;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2024-06-18
 */
@Mapper
public interface SalChanceMapper extends BaseMapper<SalChance> {
//    @Select("select * from sal_chance where chc_cust_name like concat('%',#{custName},'%') and chc_desc like concat('%',#{chcDesc},'%') and chc_due_id = #{roleId}")
    IPage<SalChance> chanceIPage(IPage<SalChance> salChanceIPage, @Param("custName") String custName,@Param("chcDesc") String chcDesc,@Param("roleId") Long roleId);

    @Select("insert into sal_chance ( chc_source, chc_cust_name, chc_title, chc_rate, chc_linkman, chc_tel, chc_desc, chc_create_by, chc_create_date, chc_due_id, chc_due_to, chc_due_date, chc_status)" +
            " values (#{chcSource},#{chcCustName},#{chcTitle},#{chcRate},#{chcLinkman},#{chcTel},#{chcDesc},#{chcCreateBy},#{chcCreateDate},#{chcDueId},#{chcDueTo},#{chcDueDate},#{chcStatus})")
    void chanceInsert(SalChance salChance);

    @Select("select * from sal_chance where chc_id = #{chcId}")
    SalChance chanceEdit(String chcId);

    @Select("update sal_chance set chc_cust_name = #{chcCustName},chc_linkman = #{chcLinkman},chc_tel=#{chcTel},chc_title=#{chcTitle},chc_source=#{chcSource},chc_rate=#{chcRate},chc_due_date=#{chcDueDate},chc_due_id=#{chcDueId},chc_desc=#{chcDesc} where chc_id=#{chcId};")
    void toUpdateChance(SalChance salChance);

    @Select("delete from sal_chance where chc_id = #{chcId};")
    void deleteByChcId(String chcId);

}
